import random
from typing import List, Union

def weighted_random_sampling(weights: Union[List[float], List[int]]):
    total_weight = sum(weights)
    r = random.uniform(0, total_weight)
    cumulative_weight = 0
    for i, weight in enumerate(weights):
        cumulative_weight += weight
        if cumulative_weight >= r:
            return i